// 关注页面逻辑
Page({
  data: {
    followList: []
  },

  onShow() {
    const list = wx.getStorageSync('followList') || [];
    this.setData({
      followList: list
    });
  },

  goToUser(e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/user/user?id=${id}`
    });
  },

  unfollow(e) {
    const id = e.currentTarget.dataset.id;
    let list = this.data.followList;
    list = list.filter(user => user.id !== id);
    wx.setStorageSync('followList', list);
    this.setData({
      followList: list
    });
    wx.showToast({ title: '已取消关注', icon: 'none' });
  }
});